package controle;

import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import model.Cerveja;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.AbstractController;
import service.SugestorService;

/**
 *
 * @author Jorge Alberto
 */
public class SugestorController extends AbstractController 
{
    
    private SugestorService sugestor;
    
    public SugestorController() 
    {
    }
    
    public void setSugestor(SugestorService sugestor)
    {
        this.sugestor = sugestor;
    }
    
    @Override
    protected ModelAndView handleRequestInternal(
            HttpServletRequest request,
            HttpServletResponse response) throws Exception 
    {
        //throw new UnsupportedOperationException("Not yet implemented");
        
        String tipo = request.getParameter("tipo");
        
        List<Cerveja> sugestoes = sugestor.sugerir(tipo );
        
        ModelAndView modelAndView = new ModelAndView("resultadoSugestao","cervejas",sugestoes);
        
        return modelAndView;
        
    }
}





